home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / MATH / MFLOAT10.ZIP / POLAR.PAS < prev    next >
Pascal/Delphi Source File  |  1993-04-28  |  1KB  |  48 lines

  1. PROGRAM polar(input, output);
  2. { *** This program demonstrates the conversion of cartesian coordinates *** }
  3. { *** to polar coordinates with mfloat numbers                          *** }
  4.  
  5. USES pfloat, crt;
  6.  
  7. VAR x, y, r, phi, xr, yr : mfloat;
  8.     ch                   : string;
  9.  
  10. BEGIN
  11.   Setmantissawords(30);
  12.   ClrScr;
  13.   writeln('          Conversion cartesian coordinates - polar coordinates');
  14.   writeln('          ====================================================');
  15.   writeln;
  16.   writeln;
  17.   writeln('Cartesian coordinates:');
  18.   REPEAT
  19.     write('x = ');
  20.     readln(ch);
  21.   UNTIL strtomf(x, ch) = 0;
  22.   REPEAT
  23.     write('y = ');
  24.     readln(ch);
  25.   UNTIL strtomf(y, ch) = 0;
  26.   writeln;
  27.   writeln('x   = ', mftoa(x,50));
  28.   writeln('y   = ', mftoa(y,50));
  29.   writeln;
  30.   writeln('Conversion to polar coordinates:');
  31.   equm(r,x);
  32.   hypotm(r,y);
  33.   equm(phi,y);
  34.   atan2m(phi,x);
  35.   writeln;
  36.   writeln('r   = ', mftoa(r,50));
  37.   writeln('phi = ', mftoa(phi,50));
  38.   writeln;
  39.   writeln;
  40.   writeln('Conversion back to cartesian coordinates:');
  41.   equm(xr, phi);
  42.   cossinm(xr, yr);
  43.   multm(xr, r);
  44.   multm(yr, r);
  45.   writeln;
  46.   writeln('x   = ', mftoa(xr,50));
  47.   writeln('y   = ', mftoa(yr,50));
  48. END.